package 蓝桥真题;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class 全球变暖 {
       static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
       final static int N=1010;
       static char g[][]=new char[N][N];
       static int dix[]={-1,0,0,1,1},diy[]={0,-1,1,0,1},n;
       static boolean st[][]=new boolean[N][N],isflood;
       static void dfs(int x,int y){
    	      if(g[x][y]!='#')return;
    	      int flag=0;
    	      for(int i=0;i<4;i++){
    	    	  int a=dix[i]+x,b=diy[i]+y;
    	    	  if(a>=0&&a<n&&b>=0&&b<n&&g[a][b]=='#'){
    	    		  flag++;
    	    	  }
    	      }
    	      if(flag==4)isflood=false;
    	      if(st[x][y])return;
    	      st[x][y]=true;
    	      for(int i=0;i<4;i++){
    	    	  int a=dix[i]+x,b=diy[i]+y;
    	    	  if(a>=0&&a<n&&b>=0&&b<n){
    	    		  dfs(a,b);
    	    	  }
    	      }
       }
       static int find(){
    	      int res=0;
    	      for(int i=1;i<n-1;i++){
    	    	  for(int j=0;j<n;j++){
    	    		  if(g[i][j]=='#'&&!st[i][j]){
    	    				  isflood=true;
    	    				  dfs(i,j);
    	    				  if(isflood)res++; 
    	    		  }
    	    	  }
    	      }
    	      return res;
       }
       public static void main(String[] args) throws  IOException {
		      n=Integer.parseInt(br.readLine());
		      for(int i=0;i<n;i++){
		    	  br.read(g[i],0,n);
		    	  br.readLine();
		      }
		      System.out.println(find());
		      
	}
}
